package in.falkeninc.umt_v0_9_8_1;

import com.actionbarsherlock.app.ActionBar;
import com.actionbarsherlock.app.SherlockFragmentActivity;
import com.actionbarsherlock.view.Menu;
import android.os.Bundle;
import android.content.res.Configuration;
import android.database.SQLException;
import android.util.Log;
import android.view.View;
import android.widget.Toast;

public class ConfigActivity extends SherlockFragmentActivity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		Toast.makeText(this, "ConfigActivity", Toast.LENGTH_SHORT).show();

		ActionBar actionBar;
		actionBar = getSupportActionBar();
		actionBar.hide();

		
		if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
			// If the screen is now in landscape mode, we can show the
			// dialog in-line with the list so we don't need this activity.
			//finish();
			//return;
		}

		if (savedInstanceState == null) {
			// During initial setup, plug in the details fragment.

			// create fragment
			ConfigFragment config = new ConfigFragment();

			// get and set the position input by user (i.e., "index")
			// which is the construction arguments for this fragment
			
			config.setArguments(getIntent().getExtras());

			//
			getSupportFragmentManager().beginTransaction().add(android.R.id.content, config).commit();
		}
	}


	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getSupportMenuInflater().inflate(R.menu.main, menu);
		return true;
	}
	
    public void dbDeleteAll(View v) {
    	
    	//builder.show();
    	DatabaseHandler db = new DatabaseHandler(this);

    	try {
            db.wipeAll();

        } catch (SQLException e) {
            db.close();
	        Log.d("dbDeletaAll error: ", e.getMessage()); // Writing Contacts to log
        }
    	//dbShowAll();	// update the view now so user sees the list is gone
    	finish();
    }
}


